<template>
    <van-nav-bar title="详情页" left-text="返回" left-arrow @click-left="() => { $router.back() }" fixed />
    <div style="height: 45px;"></div>
    <div v-html="data.goods_introduce"></div>
    <van-action-bar>
        <van-action-bar-icon icon="chat-o" text="客服" />
        <van-action-bar-icon icon="shop-o" text="店铺" />
        <van-action-bar-button color="#be99ff" type="warning" text="加入购物车" @click="gocart"/>
        <van-action-bar-button color="#7232dd" type="danger" text="立即购买" />
    </van-action-bar>
</template>

<script setup>
import { useRoute } from 'vue-router';
const route = useRoute()
console.log(route.params.goods_id);
import { detailApi } from '@/api/api'
import { ref } from 'vue';
let data = ref([])
detailApi(route.params.goods_id).then(res => {
    console.log(res);
    data.value = res.data.message
})

import { useCounterStore } from '@/stores/car.js'
// 可以在组件中的任意位置访问 `store` 变量 ✨
const store = useCounterStore()
import { useRouter } from 'vue-router';
const router = useRouter()
const gocart=()=>{
    store.addcart(data,route.params.goods_id)
    router.push('/login/gouwuche')
}
</script>

<style lang="scss" scoped></style>